package models;

import java.sql.Date;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;

import play.db.jpa.Model;

@Entity
public class MissionSkills extends Model {

	@ManyToOne
	private Skill skill;

	private Date skill_begin_date;

	private Date skill_end_date;

	public MissionSkills() {
		super();
	}

	public MissionSkills(int duree, Date skill_begin_date, Date skill_end_date,
			Skill skill) {
		super();
		this.skill_begin_date = skill_begin_date;
		this.skill_end_date = skill_end_date;
		this.skill = skill;
	}

	public Date getSkill_begin_date() {
		return skill_begin_date;
	}

	public void setSkill_begin_date(Date skill_begin_date) {
		this.skill_begin_date = skill_begin_date;
	}

	public Date getSkill_end_date() {
		return skill_end_date;
	}

	public void setSkill_end_date(Date skill_end_date) {
		this.skill_end_date = skill_end_date;
	}

	public Skill getSkill() {
		return skill;
	}

	public void setSkill(Skill skill) {
		this.skill = skill;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((skill == null) ? 0 : skill.hashCode());
		result = prime
				* result
				+ ((skill_begin_date == null) ? 0 : skill_begin_date.hashCode());
		result = prime * result
				+ ((skill_end_date == null) ? 0 : skill_end_date.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		MissionSkills other = (MissionSkills) obj;
		if (skill == null) {
			if (other.skill != null)
				return false;
		} else if (!skill.equals(other.skill))
			return false;
		if (skill_begin_date == null) {
			if (other.skill_begin_date != null)
				return false;
		} else if (!skill_begin_date.equals(other.skill_begin_date))
			return false;
		if (skill_end_date == null) {
			if (other.skill_end_date != null)
				return false;
		} else if (!skill_end_date.equals(other.skill_end_date))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "MissionSkills [skill_begin_date=" + skill_begin_date
				+ ", skill_end_date=" + skill_end_date + ", skill=" + skill
				+ "]";
	}

}
